<!--
/**************************************************
* @ bargainadd.jsp
*
* Copyright   2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/04/20, owen
*  1) first release
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8"%>
<html>
<head>
<title>新增合同信息</title>
<%@ include file="../common.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=root%>/css/caigouxitong.css" rel="stylesheet" type="text/css">
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/hi-check.js"></SCRIPT>
<SCRIPT language="JavaScript" src="js/calendar.js"></SCRIPT>
<%
String savename = (String)request.getAttribute("savename"); 
String expmessage = (String)request.getAttribute("exception_desc"); 

%>

<script language="javascript">

  <%
		if(expmessage != null){
			out.println("alert('"+expmessage+"')");
		}
	%>

			function setEnable()
			{
				if (bargainform.Radio2.checked)
				{
					document.all["attach"].disabled = false;
					bargainform.gs_bgn_mainserial.disabled = false;
				}
				else
				{
					document.all["attach"].disabled = true;
					bargainform.gs_bgn_mainserial.disabled = true;
					bargainform.gs_bgn_mainserial.value  = "";
				}
			}
			
			function setButton()
			{
				if (bargainform.Radio3.checked)
				{
					bargainform.Button4.value = "选择供应商";
					bargainform.gs_bgn_username.value="";
					bargainform.gs_bgn_userid.value="";
				}
				else
				{
					bargainform.Button4.value = "选择采购用户";
					bargainform.gs_bgn_username.value="";
					bargainform.gs_bgn_userid.value="";
				}
			}
			
			function selectCompany()
			{
				if (bargainform.Button4.value == "选择供应商")
				{
					var url = "<%=response.encodeURL(root+"/A170103.do")%>";
		            var returnv = window.open(url,null," edge: sunken ,center: Yes, help: No, resizable: Yes, status: No,height=580px, scrollbars=yes");
		            
				}
				if (bargainform.Button4.value == "选择采购用户")
				{
					var url = "<%=response.encodeURL(root+"/A170105.do")%>";
		            var returnv = window.open(url,null," edge: sunken ,center: Yes, help: No, resizable: Yes, status: No,height=580px, scrollbars=yes");
		            
				}
			}
			
			function add(){
			  
			  if(bargainform.gs_bgn_mainserial.disabled == false){
			    if(bargainform.gs_bgn_mainserial.value==""){
			     alert("主合同编号不能为空！");
			     return false;
			    }
			  }
			  
			  var iFields1 = new Array(10);
			  
              iFields1[0] = 'gs_bgn_username||客户名称||Y||1-1000||##';
              iFields1[1] = 'gs_bgn_content||合同（协议）内容||Y||1-1000||##';
              iFields1[2] = 'gs_bgn_serial||编号||Y||1-30||##';
              iFields1[3] = 'gs_bgn_signdate||签约日期||Y||1-30||##';
              iFields1[4] = 'gs_bgn_week||收/付款周期||Y||1-10||#0';
              iFields1[5] = 'gs_bgn_number||页数||N||1-3||#0';
              iFields1[6] = 'gs_bgn_filenumber||附件数||N||1-1||#ABC';
              iFields1[7] = 'gs_bgn_department||部门||N||1-50||##';
              iFields1[8] = 'gs_bgn_signuser||签约人||N||1-20||##';
              iFields1[9] = 'gs_bgn_remark||备注||N||1-1000||##';
              
              
        
		      if( HiScript.value(bargainform.name,iFields1) == false)  return false;
			  
			  
			//var str = document.getElementByName("gs_bgn_filenumber").value;
			//if (isNumber(str))
			//{
			//	alert("页数必须是有效数字！");
			//	return false;
			//}
			  
			  
			  if (bargainform.Radio3.checked){
			    if(document.bargainform.type.value!=1){
			      //alert(document.bargainform.type.value);
			      alert("客户类型与客户名称不符！");
			      return false;
			    }
			  }
			  if (bargainform.Radio4.checked){
			    if(document.bargainform.type.value!=2){
			      //alert(document.bargainform.type.value);
			      alert("客户类型与客户名称不符！");
			      return false;
			    }
			  }
			  
			  //alert(document.bargainform.gs_bgn_mainserial.value);
			  //alert(document.bargainform.gs_bgn_serial.value);
			  
			  if(document.bargainform.gs_bgn_mainserial.value==document.bargainform.gs_bgn_serial.value){
			     alert("主合同编号重复，请重新输入！");
			     return false;
			  }
			  

			  	var type=document.getElementById("gs_bgc_type1").value;
			  	var content=document.getElementById("gs_bgc_content1").value;
			  	if(type==null || type=="")
			  	{
			  		alert("费用类型至少存在一条！");
			  		return false;
			  	}
			  
			  	if(content==null || content=="")
			  	{
			  		alert("费用内容至少存在一条！");
			  		return false;
			  	}
			  	
			  var iType="";
			  var iContent="";
              
              for(var i=2;i<6;i++)
              {
              	iType=document.getElementById("gs_bgc_type"+i).value;
              	iContent=document.getElementById("gs_bgc_content"+i).value;
              	if(iType!=null && iType!="")
              	{
              		if(iContent==null || iContent=="")
              		{
              			alert("所在行的费用类型与费用内容必须填写完整或全部为空！");
			  			return false;
              		}
              	}else
              	{
              		if(iContent!=null && iContent!="")
              		{
              			alert("所在行的费用类型与费用内容必须填写完整或全部为空！");
			  			return false;
              		}
              	}

              }

			  
			  
			  
			  bargainform.action="<%= response.encodeURL(request.getContextPath() + "/A170102.do") %>";   
	          document.bargainform.submit();
	          
	          //window.location="<%= response.encodeURL(request.getContextPath() + "/A170102.do") %>?gs_bgn_serial="
			
			}
			
			function upload(){
			 
			  bargainform.action="<%= response.encodeURL(request.getContextPath() + "/A170108.do") %>";   
	          bargainform.submit();
			
			}
			</script>
</head>
<body text="#000000" bgColor="#f2f2f2" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0" onload="setEnable();">
<form name="bargainform" method="post" ENCTYPE="multipart/form-data">
			<p><br>
			</p>
			<table cellSpacing="0" cellPadding="0" width="98%" align="center" border="0">
				<tr>
					<td height="20">
						<table cellSpacing="0" cellPadding="1" width="100%" border="0">
							<tr height="20">
								<td class="mtxt_black" width="758" height="30">合同录入
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="bg_line" height="2">
					
					</td>
				</tr>
				<%
                      if(message!=null){
                    %>
				<tr>
					<td>
					<br>
					
                    <font color="red"><%=message%></font>
                    
					</td>
				</tr>
				<%
                      }
                %>
			</table>
			<br>
			
			<table class="bg_table" id="Table1" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px" cellSpacing="1"
				cellPadding="0" width="98%" align="center" border="0">
				<TR height="20">
					<TD class="bg_column" align="center" colSpan="4"><b>主体信息</b></TD>
				</TR>
				<TR height="20">
					<TD class="bg_column" align="center" width="15%">序号</TD>
					<TD class="bg_row_odd" colSpan="3"><font color="#33cc00">系统自动生成</font>
					</TD>
				</TR>
				<tr height="20">
					<TD class="bg_column" align="center" width="15%">合同类型</TD>
					<TD class="bg_row_odd" align="left" colSpan="3"><INPUT id="Radio1" onclick="setEnable();" type="radio" CHECKED value="1" name="gs_bgn_type">主合同&nbsp;&nbsp;&nbsp;&nbsp;
						<INPUT id="Radio2" onclick="setEnable();" type="radio" value="2" name="gs_bgn_type">副合同
						<div id="attach" style="DISPLAY: inline" disabled>主合同编号：
						<INPUT id="gs_bgn_mainserial" type="text" name="gs_bgn_mainserial"><font color="red">*</font>
						</div>
					</TD>
				</tr>
				<TR height="20">
					<TD class="bg_column" align="center">客户类型</TD>
					<TD class="bg_row_odd" align="left" colspan=3>
					<%if(request.getAttribute("type")==null){
					%>
						<INPUT id="Radio3" onclick="setButton();" type="radio" CHECKED value="2" name="gs_bgn_usertype">供应商&nbsp;&nbsp;&nbsp;&nbsp;
						<INPUT id="Radio4" onclick="setButton();" type="radio" value="1" name="gs_bgn_usertype">采购用户
					<%}else if(request.getAttribute("type").equals("2")){ %>
					    <INPUT id="Radio3" onclick="setButton();" type="radio" CHECKED value="2" name="gs_bgn_usertype">供应商&nbsp;&nbsp;&nbsp;&nbsp;
						<INPUT id="Radio4" onclick="setButton();" type="radio" value="1" name="gs_bgn_usertype">采购用户
				    <%}else{ %>
					     <INPUT id="Radio3" onclick="setButton();" type="radio" value="2" name="gs_bgn_usertype">供应商&nbsp;&nbsp;&nbsp;&nbsp;
						<INPUT id="Radio4" onclick="setButton();" type="radio" CHECKED value="1" name="gs_bgn_usertype">采购用户
					<%} %>
					</TD>
				</tr>
				<tr height=20>
					<TD class="bg_column" align="center" width="15%">客户名称</TD>
					<TD class="bg_row_odd" align="left" colspan=3">
						<INPUT id='provider_name' type="text" name="gs_bgn_username" style="width:60%" value="<%=request.getAttribute("gs_bgn_userid")==null? "":request.getAttribute("gs_bgn_userid") %>" readOnly>
						<font color="red">*</font>
						<INPUT id='provider_id' type="hidden" name="gs_bgn_userid" style="width:60%" value="<%=request.getAttribute("gs_bgn_userid")==null? "":request.getAttribute("gs_bgn_userid") %>">
						
						<INPUT id='type' type="hidden" name="type" style="width:60%" value="<%=request.getAttribute("type")==null? "":request.getAttribute("type") %>">
						<INPUT class="kuang" type="button" value="选择供应商" name="Button4" onclick="selectCompany();">
					</TD>
				</TR>
				<TR height="20">
					<TD class="bg_column" align="center">合同（协议）内容</TD>
					<TD class="bg_row_odd" colSpan="3" left="right">
					<INPUT style="WIDTH: 98%" type="text" name="gs_bgn_content" value="<%=request.getAttribute("gs_bgn_content")==null? "":request.getAttribute("gs_bgn_content") %>">
					 <font color="red">*</font>
					</TD>
				</TR>
				<tr>
					<TD class="bg_column" align="center">页数</TD>
					<TD class="bg_row_odd" align="left">
					<input type="text" name="gs_bgn_number" maxlength="3" value="<%=request.getAttribute("gs_bgn_number")==null? "":request.getAttribute("gs_bgn_number") %>">
					</TD>
					<TD class="bg_column" align="center">附件数</TD>
					<TD class="bg_row_odd" align="left">
					<input type="text" name="gs_bgn_filenumber" maxlength="1" value="<%=request.getAttribute("gs_bgn_filenumber")==null? "":request.getAttribute("gs_bgn_filenumber") %>">
					</TD>
				</tr>
				<tr height="20">
					<TD class="bg_column" align="center">相关文件上传</TD>
					<TD class="bg_row_odd" colSpan="3">
					<%
					if(savename!=null){
					      out.println(savename);
					      out.println("文件上传成功");
					  }else{
					%>
					<INPUT type="file" size="70" name="manufactureimage" value="请选择您要上传的文件">
				    <!--<input type="button" class="kuang" value="上传" onClick="return upload();">-->
					<%} %>
					<INPUT type="hidden" name="gs_bgn_filename" value="<%=(savename==null?"":savename)%>">
					</TD>
				</tr>
				<TR height="20">
					<TD class="bg_column" align="center">部门</TD>
					<td class="bg_row_odd">
					<INPUT id="Text3" type="text" name="gs_bgn_department" value="<%=request.getAttribute("gs_bgn_department")==null? "":request.getAttribute("gs_bgn_department") %>">
					</td>
					<TD class="bg_column" align="center">签约人</TD>
					<td class="bg_row_odd">
					<INPUT id="Text7" type="text" name="gs_bgn_signuser" value="<%=request.getAttribute("gs_bgn_signuser")==null? "":request.getAttribute("gs_bgn_signuser") %>">
					</td>
				</TR>
				<tr height="20">
					<TD class="bg_column" align="center">签约日期</TD>
					<TD class="bg_row_odd" align="left">
					<input id="Text27" onfocus="setday(this)" readOnly name="gs_bgn_signdate" value="<%=request.getAttribute("gs_bgn_signdate")==null? "":request.getAttribute("gs_bgn_signdate") %>">
					 <font color="red">*</font>
					</TD>
					<TD class="bg_column" align="center">终止日期</TD>
					<TD class="bg_row_odd" align="left">
					<input id="Text4" onfocus="setday(this)" readOnly name="gs_bgn_enddate" value="<%=request.getAttribute("gs_bgn_enddate")==null? "":request.getAttribute("gs_bgn_enddate") %>">
					</TD>
				</tr>
				<TR height="20">
					<TD class="bg_column" align="center">期限</TD>
					<td class="bg_row_odd">
					<INPUT id="Text8" type="text" name="gs_bgn_term" maxlength="10" value="<%=request.getAttribute("gs_bgn_term")==null? "":request.getAttribute("gs_bgn_term") %>"></td>
					<TD class="bg_column" align="center">卷号</TD>
					<td class="bg_row_odd">
					<INPUT id="Text9" type="text" name="gs_bgn_vol" maxlength="20" value="<%=request.getAttribute("gs_bgn_vol")==null? "":request.getAttribute("gs_bgn_vol") %>"></td>
				</TR>
				<TR height="20">
					<TD class="bg_column" align="center">编号</TD>
					<td class="bg_row_odd">
					<INPUT type="text" name="gs_bgn_serial" maxlength="30" value="<%=request.getAttribute("gs_bgn_serial")==null? "":request.getAttribute("gs_bgn_serial") %>">
					 <font color="red">*</font></td>
					<TD class="bg_column" align="center">归卷日期</TD>
					<td class="bg_row_odd">
					<input id="Text11" onfocus="setday(this)" readOnly name="gs_bgn_returneddate" value="<%=request.getAttribute("gs_bgn_returneddate")==null? "":request.getAttribute("gs_bgn_returneddate") %>">
					</td>
				</TR>
				<TR height="20">
					<TD class="bg_column" align="center">收/付款周期</TD>
					<TD class="bg_row_odd" colSpan="3" left="right">
					<INPUT id="Text8" type="text" name="gs_bgn_week" maxlength="10" value="<%=request.getAttribute("gs_bgn_week")==null? "":request.getAttribute("gs_bgn_week") %>"> 天
					<font color="red">*</font>
					</TD>
				</TR>
				<TR height="20">
					<TD class="bg_column" align="center">备注</TD>
					<TD class="bg_row_odd" colSpan="3" left="right">
					<TEXTAREA id="Textarea2" style="WIDTH: 98%" name="gs_bgn_remark" rows="5" cols="80"><%=request.getAttribute("gs_bgn_remark")==null? "":request.getAttribute("gs_bgn_remark") %></TEXTAREA>
					</TD>
				</TR>
			</table>
			<br>
			<table class="bg_table" id="Table1" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px" cellSpacing="1"
				cellPadding="0" width="98%" align="center" border="0">
				<TR height="20">
					<TD class="bg_column" align="center" colSpan="2"><b>费用信息</b></TD>
				</TR>
				<tr>
					<TD class="bg_column" align="center"><b>类型</b></TD>
					<TD class="bg_column" align="center"><b>内容</b></TD>
				</tr>
				<tr>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_type1" name="gs_bgc_type" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_type1")==null? "":request.getAttribute("gs_bgc_type1") %>">
					<font color="red">*</font>
					</TD>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_content1" name="gs_bgc_content" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_content1")==null? "":request.getAttribute("gs_bgc_content1") %>">
					<font color="red">*</font>
					</TD>
				</tr>
				<tr>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_type2" name="gs_bgc_type" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_type2")==null? "":request.getAttribute("gs_bgc_type2") %>">
					&nbsp;</TD>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_content2" name="gs_bgc_content" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_content2")==null? "":request.getAttribute("gs_bgc_content2") %>">
					&nbsp;</TD>
				</tr>
				<tr>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_type3" name="gs_bgc_type" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_type3")==null? "":request.getAttribute("gs_bgc_type3") %>">
					&nbsp;</TD>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_content3" name="gs_bgc_content" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_content3")==null? "":request.getAttribute("gs_bgc_content3") %>">
					&nbsp;</TD>
				</tr>
				<tr>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_type4" name="gs_bgc_type" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_type4")==null? "":request.getAttribute("gs_bgc_type4") %>">
					&nbsp;</TD>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_content4" name="gs_bgc_content" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_content4")==null? "":request.getAttribute("gs_bgc_content4") %>">
					&nbsp;</TD>
				</tr>
				<tr>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_type5" name="gs_bgc_type" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_type5")==null? "":request.getAttribute("gs_bgc_type5") %>">
					&nbsp;</TD>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_content5" name="gs_bgc_content" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_content5")==null? "":request.getAttribute("gs_bgc_content5") %>">
					&nbsp;</TD>
				</tr>
				<tr>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_type6" name="gs_bgc_type" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_type6")==null? "":request.getAttribute("gs_bgc_type6") %>">
					&nbsp;</TD>
					<TD class="bg_column" align="center">
					<INPUT type="text" id="gs_bgc_content6" name="gs_bgc_content" style="WIDTH: 90%" value="<%=request.getAttribute("gs_bgc_content6")==null? "":request.getAttribute("gs_bgc_content6") %>">
					&nbsp;</TD>
				</tr>
			</table>
		</form>
		<p align="center">
		
				<input class="kuang" onclick="return add()" type="button" value="保存" height="24" width="58">&nbsp; 
				<!--<INPUT id="Button2" onclick="alert('合同新增成功！');" type="button" value="保存" name="Button1">-->
		</p>
	    <!-- 
	    <form name="uploadform" method="post" ENCTYPE="multipart/form-data">
		<INPUT type="file" size="50" name="manufactureimage">
					<INPUT class="kuang" type="button" value="上传" onclick="return upload()">
		</form>
		 -->
	</body>
	
</html>